Skip to content

通过DMA读取指定地址的整数 - DmaReadInt

函数简介

通过 DMA 读取指定地址的整数值,支持多种整数类型和 CE 地址格式。(高级版功能,普通版无法使用)

接口名称

DmaReadInt

DLL调用

c
int64_t OLA_CALL_TYPE DmaReadInt(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT addr, int32_t type);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
deviceId长整数型设备ID
pid整数型进程 PID
addr字符串地址,支持 CE 数据格式
type整数型整数类型:0=32位有符号, 1=16位有符号, 2=8位有符号, 3=64位, 4=32位无符号, 5=16位无符号, 6=8位无符号

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
long deviceId = ola.DmaAddDevice(1);
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
long value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
long deviceId = ola.DmaAddDevice(1);
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
long value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
# 先添加 DMA 设备,返回的 deviceId 用于后续读写
deviceId = ola.DmaAddDevice(1)
# type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
long deviceId = ola.DmaAddDevice(1);
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
long value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0);
cpp
var ola = com("OlaPlug.OlaSoft")
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
var deviceId = ola.DmaAddDevice(1)
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
var value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 先添加 DMA 设备,返回的 deviceId 用于后续读写
deviceId = ola.DmaAddDevice(1)
' type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
' 先添加 DMA 设备,返回的 deviceId 用于后续读写
deviceId = ola.DmaAddDevice(1)
' type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
value = ola.DmaReadInt(deviceId, 1234, “0x401000“, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
var deviceId = ola.DmaAddDevice(1);
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
var value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
长整数 deviceId = ola.DmaAddDevice(1)
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
长整数 value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 先添加 DMA 设备,返回的 deviceId 用于后续读写
long deviceId = ola.DmaAddDevice(1);
// type=0 表示 32 位有符号整数,addr 支持 CE 地址格式
long value = ola.DmaReadInt(deviceId, 1234, "0x401000", 0);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long deviceId = DmaAddDevice(instance, 1);
long value = DmaReadInt(instance, deviceId, 1234, "0x401000", 0);
csharp
long instance = CreateCOLAPlugInterFace();
long deviceId = DmaAddDevice(instance, 1);
long value = DmaReadInt(instance, deviceId, 1234, "0x401000", 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
deviceId = DmaAddDevice(instance, 1)
value = DmaReadInt(instance, deviceId, 1234, "0x401000", 0)

返回值

长整数型:返回读取到的整数值(64 位)。